package com.mutual.controller.finance;

import java.math.BigDecimal;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.mutual.base.controller.BaseController;
import com.mutual.base.controller.BaseController.Status;
import com.mutual.entity.Finance;
import com.mutual.service.FinanceService;

@Controller
@RequestMapping("/finance")
public class FinanceController extends BaseController {

	@Resource
	private FinanceService financeService;
	
	@RequestMapping("/addYuE.htm")
	public ModelAndView addYue(Finance item){
		try {
			Finance finance = financeService.selectByPrimaryKey(item.getId());
			if(null == finance){
				finance = new Finance();
				finance.setMemberId(item.getId());
				finance.setNumber(item.getNumber());
				finance.setGroomAward(new BigDecimal(0));
				finance.setTeamAward(new BigDecimal(0));
				financeService.insertSelective(finance);
			}else{
				financeService.updateYuE(item.getId(),item.getNumber());
			}
			return ajaxJSON(Status.success);
		} catch (Exception e) {
			e.printStackTrace();
			logger.error("修改余额出现错误："+e.getMessage(),e);
			return ajaxJSON(Status.error,"添加余额出现错误，请联系管理员。");
		}
	}
	
}
